package com.personal.gateway.flinkAllCommand.flinkMetrics;

import com.personal.gateway.custom.customEnum.flinkCommandEnum.FlinkMetricsEnum;
import com.personal.gateway.custom.customEnum.flinkCommandEnum.FlinkTargetEnum;
import com.personal.gateway.flinkAllCommand.configurationOption.ConfigurationOption;
import com.personal.gateway.flinkAllCommand.configurationOption.configurationType.AbstractConfigurationTypeClass;

/**
 * @author BigHead
 * @date 2022/1/19 17:16
 * @description FlinkEnvironmentTypeClass
 */
public abstract class FlinkMetricsTypeClass extends AbstractConfigurationTypeClass {

    public static final Class<AbstractConfigurationTypeClass> FLINK_METRICS_TYPE_CLASS = (Class<AbstractConfigurationTypeClass>) (Class<?>) FlinkMetricsTypeClass.class;

    protected FlinkMetricsEnum[] flinkTargetEnums;

    public FlinkMetricsTypeClass(){
        this.flinkTargetEnums = setFlinkTargetEnums();
    }

    /**
     * 自定义 返回的FlinkTargetEnum 类型
     * @return 数组
     */
    protected abstract FlinkMetricsEnum[] setFlinkTargetEnums();

    @Override
    public boolean checkAntecedent(ConfigurationOption<?, ?> configurationOption){
        FlinkMetricsEnum flinkMetricsEnum = (FlinkMetricsEnum)configurationOption.getConfigurationType().getValue();
        for (FlinkMetricsEnum targetFlinkMetricsEnum : flinkTargetEnums){
            if (flinkMetricsEnum.equals(targetFlinkMetricsEnum)){
                return true;
            }
        }
        return false;
    }
}
